package cn.zz.veggie.application.packer;

import cn.zz.veggie.model.domain.User;
import cn.zz.veggie.web.types.vo.his.HisUserVo;
import cn.zz.veggie.web.types.vo.mgmt.MgmtUserBriefVo;
import cn.zz.veggie.web.types.vo.mgmt.user.MgmtUserVo;

/**
 * @author zhongq
 * @since 2024/5/22
 */
public class UserPacker {
	public static HisUserVo toHisUserVo(User user) {
		final  HisUserVo vo = new  HisUserVo();
		vo.setId(user.getId());
		vo.setUsername(user.getUsername());
		vo.setStoreName(user.getStoreName());
		return vo;
	}

	public static MgmtUserBriefVo toMgmtUserBriefVo(User user) {
		final MgmtUserBriefVo vo = new MgmtUserBriefVo();
		injectBrief(user, vo);
		return vo;
	}

	public static MgmtUserVo toMgmtUserVo(User user) {
		final  MgmtUserVo vo = new MgmtUserVo();
		injectBrief(user, vo);
		vo.setMobile(user.getMobile());
		vo.setCreatedAt(user.getCreatedAt());
		vo.setUpdatedAt(user.getUpdatedAt());
		return vo;
	}

	public static void injectBrief(User user, MgmtUserBriefVo vo) {
		vo.setId(user.getId());
		vo.setUsername(user.getUsername());
		vo.setStoreName(user.getStoreName());
		vo.setStoreAddress(user.getStoreAddress());
	}
}